argc=$#

help() {
    echo 'manage.sh <start|stop|restart|test>'
}

if [ $argc -eq 0 ]; then
    help
    exit
fi

op=$1
if [ $op = 'start' ]; then
    forever start server.js
elif [ $op = 'test' ]; then
    node server.js
elif [ $op = 'stop' ]; then
    forever stop server.js
elif [ $op = 'restart' ]; then
    forever stop server.js
    forever start server.js
else
    echo 'Invalid action!'
    help
    exit
fi
